package com.cn.wanxi.dao.impl;

import com.cn.wanxi.dao.CuisineDao;
import com.cn.wanxi.model.CuisineModel;
import com.cn.wanxi.util.JDBC;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class CuisineImpl implements CuisineDao {
    @Override
    public List<CuisineModel> findAll() {
        String sql="select * from tab_cuisine";
        ResultSet resultSet= JDBC.getResultSet(sql);
        List<CuisineModel> list=new ArrayList<>();
        try
        {
            while (resultSet.next()){
                CuisineModel cuisineModel=new CuisineModel();
                cuisineModel.setId(resultSet.getInt("id"));
                cuisineModel.setName(resultSet.getString("name"));
                list.add(cuisineModel);
            }
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return list;
    }
}
